<template>
	<view class="p20">
		<view class="pt40 flex row-center">
			<imgList hide @setImg="e=>{form.avatar_img=e.path,form.avatar=e.id}" ref="img" />
			<u-avatar :src="form.avatar_img||''" @click="$refs.img.upImg('setImg')" size="130" show-level
				level-icon="camera-fill" />
		</view>
		<view class="h70"></view>
		<form-list ref="form" :list="list"></form-list>
		<view class="h120"></view>
		<view class="pf bottom0 left0 bg-fff w-max">
			<view class="p20">
				<u-button type="warning" ripple @click="submit">保存修改</u-button>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				form: {
					avatar: "", //	整型	非必填	-	-	头像
					avatar_img: "", //	整型	非必填	-	-	头像
				}
			};
		},
		onLoad() {
			let user = this.$user||''
			for (let key in this.form) {
				this.form[key] = this.$user[key]
			}
			this.list = [{
					name: '姓名',
					field: 'name',
					value: user.name || ''
				},
				{
					name: '认证',
					id: 'certificate',
					rightIcon: false,
					disabled: true,
					value: user.certificate ? '已认证' : '未认证'
				},
				{
					type: 'select',
					name: '当前状态',
					field: 'work',
					rightIcon: false,
					value: user.work == 1 ? '上班' : '下班',
					value_id: user.work,
					list: [{
							label: '上班',
							value: '1'
						},
						{
							label: '下班',
							value: '0'
						},
					]
				},
				{
					type: 'textarea',
					name: '个人简介',
					field: 'profile',
					value: '',
					rightIcon: false,
				},
			]
			
		},
		methods: {
			submit() {
				let form = {
					...this.form,
					...this.$refs.form.submit()
				}
				this.$request('/master/my/editInfo', form).then(res => {
					this.$msg(res.msg)
					setTimeout(this.$navBack, 800)
				})
			}
		}
	}
</script>

<style lang="scss">

</style>
